var Controllers = {};
var Views = {};

Controllers.Global = function(){this.init();};
Controllers.Global.Properties = {
	META_TOGGLE_BTN: '.metaToggleBtn .iBtn',
	META_TOGGLE_EXPANDED: 'toggler',
	META_TOGGLE_COLLAPSED: 'toggler-collapsed',
	META_TOGGLE_LABEL: '.metaToggleBtn span.labelTxt',
	META_TOGGLE_EXPAND_LANG: 'EXPAND INFO',
	META_TOGGLE_COLLAPSE_LANG: 'COLLAPSE INFO',
	INNER_META_HEIGHT: null
};
Controllers.Global.prototype = {
	_p: Controllers.Global.Properties,
	init:
	function()
	{
		this.bindButtons(this);
		this.getMetaDOMInfo();
	},
	
	
	bindButtons:
	function(_t)
	{
		//meta toggle btn
		$('.metaToggleBtn .iBtn').bind('click',{t:_t},function(event){
			event.data.t.toggleMetaBtn(event.data.t);
		});
	},
	
	/**
	 * Gather information on the meta show/hide module.
	 * @function
	 **/
	getMetaDOMInfo:
	function()
	{
		this._p.INNER_META_HEIGHT = $('.innerMeta').height();
		var t = this;
		$('.innerMeta').height(0);
		/** Uncomment this to make the default state EXPANDED.
		 **
		var meta_to = setTimeout(function(){
			t.toggleMetaBtn(t);
			clearTimeout(meta_to);
		},2000);
		 **
		 **/
	},
	
	toggleMetaBtn:
	function(t)
	{
		//collapse, do expand
		if( $(t._p.META_TOGGLE_BTN).hasClass(t._p.META_TOGGLE_COLLAPSED) )
		{
			$(t._p.META_TOGGLE_LABEL).html(t._p.META_TOGGLE_COLLAPSE_LANG);
			t.expandMeta();
		}
		//expanded, do collapse
		else
		{
			$(t._p.META_TOGGLE_LABEL).html(t._p.META_TOGGLE_EXPAND_LANG);
			t.collapseMeta();
		}
		$(t._p.META_TOGGLE_BTN).toggleClass('toggler');
		$(t._p.META_TOGGLE_BTN).toggleClass('toggler-collapsed');
	},
	
	/**
	 * Collapses the meta data block.
	 * @function
	 **/
	collapseMeta:
	function()
	{
		//animate
		$('.innerMeta').animate({
			height: 0 + 'px'
		},700,'easeOutQuart',function(){});
	},
	
	/**
	 * Expands the meta data block.
	 * @function
	 **/
	expandMeta:
	function()
	{
		//animate
		$('.innerMeta').animate({
			height: this._p.INNER_META_HEIGHT + 'px'
		},700,'easeOutQuart',function(){});
	}
};

$(function() {
	//global controller
	var _gc = new Controllers.Global();
});



/*

$("#" + this._c.MODULE_ID).animate({
				height: this._c.EXPANDED_HEIGHT + "px"
			}, 600, 'easeOutQuart', function(){ $("#" + Nextel.Assistant.Constants.ARROWS_ID).toggleClass( Nextel.Assistant.Constants.ARROWS_DOWN_CLASS ); });


*/